/**
 * Created by Administrator on 2017/9/27.
 */
//引用
requirejs.config({
    baseUrl:"../js",
    paths:{
        //指定模块
        "jquery":"lib/jquery-3.2.1",
    }
})
requirejs(["jquery"],function ($){
    $(function () {
        $('.loadbox').load('my_load/myOrder.html',function () {});
        //load加载
        $('.m_left li').on("click",function () {
            switch ($(this).index()){
                case 0:
                    $('.loadbox').load('my_load/myOrder.html',function () {});
                    break;
                case 1:
                    $('.loadbox').load('my_load/judge.html',function () {});
                    break;
                case 2:
                    $('.loadbox').load('my_load/returnGoods.html',function () {});
                    break;
                case 3:
                    $('.loadbox').load('my_load/myWallet.html',function () {});
                    break;
                case 4:
                    $('.loadbox').load('my_load/myCollect.html',function () {});
                    break;
                case 5:
                    $('.loadbox').load('my_load/myDaling.html',function () {});
                    break;
            }
        });

        //购物车的隐藏与展开
        var flag=false;
        $("#cartSlide").on("click",function () {
            if(flag){
                $("#sidecart").animate({right:"-280px"},500,function () {
                    $("#cartSlide").css("backgroundColor","#333");
                    flag=false;
                });
            }else{
                $("#sidecart").animate({right:"0px"},500,function () {
                    $("#cartSlide").css("backgroundColor","#e14958");
                    flag=true;
                });
            }
        });

        //返回顶部
        $(document).on("scroll",function () {
            var maxHeight=$("#header").height()+$("#nav").height();
            if($(this).scrollTop()>maxHeight){
                $('.backtop').css('display',"block");
            }else {
                $('.backtop').css('display',"none");
            }
        });
        $('.backtop').on("click",function () {
            $(document).css("top","0px");
        });


        //判断是否当前是否有用户;并获取值
        function GetQueryString(name)
        {
            var reg
                = new RegExp("(^|&)"+
                name +"=([^&]*)(&|$)");
            var r
                = window.location.search.substr(1).match(reg);
            if(r!=null)return  unescape(r[2]);return null;
        }
        console.log(GetQueryString('utel'));
        if(GetQueryString('utel')){
            $("#utel").html("欢迎您,"+GetQueryString('utel'));
            $("#utel").attr('href',"mine.html?utel="+GetQueryString('utel'));
            $("#utel").parent('li').siblings('li').eq(1).find('a').attr('href',"shopcart.html?utel="+GetQueryString('utel'));
            $(".logo").find('a').attr('href',"index.html?utel="+GetQueryString('utel'));
        }
    })
})